﻿using Finance.Api.Read.Applications.Commands.库存盘点;
using Finance.Api.Read.Dtos;
using Finance.Domain;
using Finance.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Finance.Api.Read.Controllers.库存盘点
{
    /// <summary>
    /// 库存盘点-Api(读)
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ChecksController : ControllerBase
    {
        private readonly IMediator mediator;
        private readonly ILogger<ChecksController> logger;

        public ChecksController(IMediator mediator,ILogger<ChecksController> logger)
        {
            this.mediator = mediator;
            this.logger = logger;
        }

        /// <summary>
        /// 库存盘点信息显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<ApiPaging<List<CheckDto>>>> GetCheckList([FromQuery]CheckQueryCommand request)
        {
            logger.LogInformation("库存盘点信息显示");
            return await mediator.Send(request);
        }

        /// <summary>
        /// 盘点明细信息查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<DetailDto>>> GetDetailList([FromQuery]DetailQueryCommand request)
        { 
            return await mediator.Send(request);
        }

        /// <summary>
        /// 产品信息分页查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<ApiPaging<List<ProductDto>>>> GetProductList([FromQuery]ProductQueryCommand request)
        { 
            return await mediator.Send(request);
        }

        /// <summary>
        /// 出库记录查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<OutRecordDto>>> GetOutRecordList([FromQuery]OutRecordQueryCommand request)
        { 
            return await mediator.Send(request);
        }

        /// <summary>
        /// 入库记录查询
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<List<InRecordDto>>> GetInRecordList([FromQuery]InRecordQueryCommand request)
        { 
            return await mediator.Send(request);
        }
    }
}
